﻿@using LKVMLMADMIN.Models;
@using PagedList.Mvc;
@using System.Globalization;
@{
    ViewBag.Title = "Danh sách tin tức";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}
<div id="wrapper">
    <div class="row">
        <div style=" min-height: 90px; padding-left: 30px; ">
            <h3 class="page-header">@ViewBag.Title</h3>
            @using (Html.BeginForm("ListNews", "News", FormMethod.Post, new { @class = "form-inline" }))
            {

                @Html.TextBox("keyword", "", new { @id = "date_search", @placeholder = "nhâp từ khóa", @class = "form-control" })
                <button type="submit" class="btn_submit btn btn-default">Tìm kiếm</button>

            }
            <a href="@Url.Action("NewsDetail", "News", new { id = 0, notice = "" })" style="float:right !important;margin-right:30px;" class="btn_submit btn btn-default">Thêm mới</a>
        </div>
    </div>
    <!-- /.row -->
    <div class="row">
        <div class="col-lg-12">
            <div class="panel-body">
                <div class="dataTable_wrapper">
                    <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                        <thead>
                            <tr>
                                <th>STT</th>
                                <th>Tên bài viết</th>
                                <th>Danh mục</th>
                                <th>Ngày tạo </th>
                                <th>Người tạo</th>
                                <th>Tùy chọn</th>
                            </tr>
                        </thead>
                        <tbody>
                            @{int j = 0;}
                            @foreach (var item in ViewBag.listNews)
                            {
                                j++;
                                <tr>
                                    <td>@j</td>
                                    <td>@item.TenBaiViet</td>
                                    <td>@item.TenDanhMuc</td>
                                    <td>@String.Format("{0:dd/MM/yyyy}", item.NgayTao)</td>
                                    <td>@item.NguoiTao</td>
                                    <td><a href="@Url.Action("NewsDetail", "News", new { id = item.ID })">Xem</a> &nbsp;<a href="@Url.Action("DeleteNews", "News", new { Id = item.ID })">Xóa</a></td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </div>
                <!-- /.table-responsive -->
            </div>
            <!-- /.panel-body -->
        </div>
    </div>
    <div class="row">
        <div class="dataTables_paginate paging_full_numbers pull-right" style="padding-right:30px;margin-top:-35px !important;" id="dyntable_paginate">

            @Html.PagedListPager((PagedList.IPagedList)Model, page => Url.Action("ListNews", new { page }))
        </div>
    </div>

</div>